{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import display, Markdown\n",
    "import snakemd\n",
    "\n",
    "import fitfile\n",
    "from garmindb import GarminConnectConfigManager\n",
    "from garmindb.garmindb import GarminDb, Attributes, File\n",
    "\n",
    "\n",
    "gc_config = GarminConnectConfigManager()\n",
    "db_params_dict = gc_config.get_db_params()\n",
    "garmin_db = GarminDb(db_params_dict)\n",
    "\n",
    "measurement_system = Attributes.measurements_type(garmin_db)\n",
    "unit_strings = fitfile.units.unit_strings[measurement_system]\n",
    "distance_units = unit_strings[fitfile.units.UnitTypes.distance_long]\n",
    "\n",
    "doc = snakemd.new_doc()\n",
    "\n",
    "doc.add_heading(\"GarminDb Statistics\")\n",
    "doc.add_paragraph(\"Metadata for data in the database.\")\n",
    "\n",
    "file_stats = [\n",
    "    ['All', File.row_count(garmin_db)]\n",
    "]\n",
    "for file_type_name in [file_type.name for file_type in File.FileType]:\n",
    "    records = File.row_count(garmin_db, File.type, file_type_name)\n",
    "    if records > 0:\n",
    "        file_stats.append([file_type_name, records])\n",
    "doc.add_table(['Type', 'Files'], file_stats)\n",
    "\n",
    "display(Markdown(str(doc)))"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "d4f50e87ad7f9cd136d9d3dcf547b8236ee2585f92d0ab7c53dfb80e44e3fae9"
  },
  "kernelspec": {
   "display_name": "Python 3.9.5 64-bit ('.venv')",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
